<template>
	<view class="tab_bar flex">
		<view class="item" v-for="item in list" @tap="changePath(item)">
			<view class="center_menu col_between" v-if="item.id==3">
				<view class="center_icon flex_center">
					<uni-icons custom-prefix="iconfont" :type="item.icon" size="23"
						:color="id==item.id?'#ffffff':'#5c566e'"></uni-icons>
				</view>
				<view class="text" :class="id==item.id?'active_text':''">{{item.text}}</view>
			</view>
			<view class="menu col_center" v-else>
				<view class="icon">
					<uni-icons custom-prefix="iconfont" :type="item.icon" size="25"
						:color="id==item.id?'#ffffff':'#5c566e'"></uni-icons>
				</view>
				<view class="text" :class="id==item.id?'active_text':''">{{item.text}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "tab-view",
		props: ["id"],
		data() {
			return {
				list: [{
					id: 1,
					pagePath: "/pages/home/home",
					text: this.$i18n.t("首页"),
					icon: "icon-home"
				}, {
					id: 2,
					pagePath: "/pages/stock/stock",
					text: this.$i18n.t("股票"),
					icon: "icon-stock"
				}, {
					id: 3,
					pagePath: "/pages/deal/deal",
					text: this.$i18n.t("交易"),
					icon: "icon-deal"
				}, {
					id: 4,
					pagePath: "/pages/record/record",
					text: this.$i18n.t("资金记录"),
					icon: "icon-record"
				}, {
					id: 5,
					pagePath: "/pages/mine/mine",
					text: this.$i18n.t("我的"),
					icon: "icon-mine"
				}]
			};
		},
		methods: {
			changePath(opt) {
				if (this.id == opt.id) {
					console.log("当前页面")
					return
				}
				uni.switchTab({
					url: opt.pagePath
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tab_bar {
		width: 100%;
		height: 124rpx;
		background: #151630;
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 998;

		.item {
			flex: 1;
			height: 100%;

			.text {
				font-size: 24rpx;
				font-family: Adobe Heiti Std;
				font-weight: 400;
				color: #46445c;
			}

			.active_text {
				color: #fff;
			}
		}

		.menu {
			width: 100%;
			height: 100%;
		}

		.center_menu {
			width: 100%;
			height: 100%;
			position: relative;

			.center_icon {
				width: 106rpx;
				height: 106rpx;
				background: #4c3d89;
				border-radius: 50%;
				position: absolute;
				left: 50%;
				top: -32rpx;
				transform: translateX(-50%);
			}

			.text {
				width: 100%;
				text-align: center;
				position: absolute;
				left: 0;
				bottom: 5px
			}
		}

	}
</style>